package com.qfmy.webapp.service.impl.novel;

import com.qfmy.webapp.mapper.novel.TagMapper;
import com.qfmy.webapp.service.novel.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.web.app.service.impl.novel
 * @date 2025/11/13
 * @description 标签
 */
@Service
public class TagServiceImpl implements TagService {

    /**
     * 注入mapper
     */
    @Autowired
    private TagMapper tagMapper;

    /**
     * 获取标签
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<String> getTags(Integer pageNum, Integer pageSize) {
        //校验分页
        if(pageNum <= 0 || pageSize <= 0)
        {
            pageNum = 1;
            pageSize = 4;
        }
        //计算分页
        int offset = (pageNum - 1) * pageSize;
        //查询
        List<String> tags = tagMapper.getTags(offset, pageSize);
        if(tags != null)
        {
            return tags;
        }
        return Collections.emptyList();
    }
}
